package main

import (
	"fmt"
)

//切片提供了计算容量的方法 cap() 可以测量切片最长可以达到多少。
func main() {
	the_array := [6]int{1, 2, 3, 4, 5, 6}
	the_slice := make([]int, 3, 3)
	debug_slice(the_slice, "test")

	fmt.Println(cap(the_slice))

	the_slice = the_array[:]
	fmt.Println(cap(the_slice))
	debug_slice(the_slice, "test")
}

func debug_slice(the_slice []int, msg string) {
	fmt.Println(msg)
	for i, item := range the_slice {
		fmt.Printf("the_slice[%d]=%d\n", i, item)
	}
}
